#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/10/7 17:44
# @Author  : AshJo
# @Desc    : 守护进程
# @Filename: daemon.py
# @Version : v1.0
"""

import time
from multiprocessing import Process


def son1():
    while True:
        print('---> in son1')
        time.sleep(1)


def son2():
    for i in range(10):  # 执行10s
        print('in son2')
        time.sleep(1)


if __name__ == '__main__':  # 3s
    p1 = Process(target=son1)
    p1.daemon = True  # p1是守护进程
    p1.start()
    p2 = Process(target=son2)
    p2.start()
    time.sleep(3)
    print('in main')
    p2.join()  # 等待p2结束才结束
